<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
       var time = new Date();
       console.log(time); //Tue Aug 31 2021 21:36:45 GMT+0800 (中国标准时间)

       var year = time.getFullYear(); //年份
       var month = time.getMonth() + 1; //月份要加1，月份从0开始，11结束，所以国内习惯要+1
       var day = time.getDate(); //几号
       var hour = time.getHours(); //小时
       var mm = time.getMinutes(); //分钟
       var s = time.getSeconds(); //秒
       var ms = time.getMilliseconds(); //毫秒  1000毫秒 = 1秒

       var timestr = year+"年"+month+"月"+day+"号 "+hour+"时"+mm+"分"+s+"秒"+ms+"毫秒";
       console.log(timestr);
    </script>
</body>
</html>